package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-06-01
 * Time: 13:13
 */
class Student implements Cloneable {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test {
    public static void func() throws NullPointerException{
        int[] array = {1,2,3,4,5};
        try{
            array = null;
            System.out.println(array[8]);
            System.out.println("s");
        }catch(NullPointerException e){
            throw new NullPointerException();
        }
    }
    public static void main(String[] args) {
        try{
            func();
        }catch(NullPointerException e){
            System.out.println("NullPointerException异常处理中....");
        }
    }
    public static void func(int a){
        if(a == 0){
            throw new ArithmeticException("a == 0");
        }
    }
    public static void main2(String[] args) {
        try{
            func(0);
        }catch(ArithmeticException e){
            System.out.println("ArithmeticException异常处理中....");
            e.printStackTrace();
        }
        System.out.println("hhhh");
    }
    public static void main1(String[] args) throws CloneNotSupportedException{//编译时异常/受查异常
        Student stu1 = new Student("小黄",12);
        Student stu2 = (Student)stu1.clone();
        System.out.println();
    }
}
